home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / StyledEditorKit.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  4.6 KB  |  65 lines

  1. package javax.swing.text;
  2.  
  3. import javax.swing.Action;
  4. import javax.swing.JComponent;
  5. import javax.swing.JEditorPane;
  6.  
  7. public class StyledEditorKit extends DefaultEditorKit {
  8.    private static final ViewFactory defaultFactory = new StyledViewFactory();
  9.    Element currentRun;
  10.    Element currentParagraph;
  11.    MutableAttributeSet inputAttributes = new 1(this);
  12.    private AttributeTracker inputAttributeUpdater = new AttributeTracker(this);
  13.    private static final Action[] defaultActions = new Action[]{new FontFamilyAction("font-family-SansSerif", "SansSerif"), new FontFamilyAction("font-family-Monospaced", "Monospaced"), new FontFamilyAction("font-family-Serif", "Serif"), new FontSizeAction("font-size-8", 8), new FontSizeAction("font-size-10", 10), new FontSizeAction("font-size-12", 12), new FontSizeAction("font-size-14", 14), new FontSizeAction("font-size-16", 16), new FontSizeAction("font-size-18", 18), new FontSizeAction("font-size-24", 24), new FontSizeAction("font-size-36", 36), new FontSizeAction("font-size-48", 48), new AlignmentAction("left-justify", 0), new AlignmentAction("center-justify", 1), new AlignmentAction("right-justify", 2), new BoldAction(), new ItalicAction(), new UnderlineAction()};
  14.  
  15.    public Object clone() {
  16.       return new StyledEditorKit();
  17.    }
  18.  
  19.    public Document createDefaultDocument() {
  20.       return new DefaultStyledDocument();
  21.    }
  22.  
  23.    protected void createInputAttributes(Element var1, MutableAttributeSet var2) {
  24.       var2.removeAttributes(var2);
  25.       var2.addAttributes(var1.getAttributes());
  26.       var2.removeAttribute(StyleConstants.ComponentAttribute);
  27.       var2.removeAttribute(StyleConstants.IconAttribute);
  28.       var2.removeAttribute("$ename");
  29.       var2.removeAttribute(StyleConstants.ComposedTextAttribute);
  30.    }
  31.  
  32.    public void deinstall(JEditorPane var1) {
  33.       ((JTextComponent)var1).removeCaretListener(this.inputAttributeUpdater);
  34.       ((JComponent)var1).removePropertyChangeListener(this.inputAttributeUpdater);
  35.       this.currentRun = null;
  36.       this.currentParagraph = null;
  37.    }
  38.  
  39.    public Action[] getActions() {
  40.       return TextAction.augmentList(super.getActions(), defaultActions);
  41.    }
  42.  
  43.    public Element getCharacterAttributeRun() {
  44.       return this.currentRun;
  45.    }
  46.  
  47.    public MutableAttributeSet getInputAttributes() {
  48.       return this.inputAttributes;
  49.    }
  50.  
  51.    public ViewFactory getViewFactory() {
  52.       return defaultFactory;
  53.    }
  54.  
  55.    public void install(JEditorPane var1) {
  56.       ((JTextComponent)var1).addCaretListener(this.inputAttributeUpdater);
  57.       ((JComponent)var1).addPropertyChangeListener(this.inputAttributeUpdater);
  58.       Caret var2 = ((JTextComponent)var1).getCaret();
  59.       if (var2 != null) {
  60.          this.inputAttributeUpdater.updateInputAttributes(var2.getDot(), var2.getMark(), var1);
  61.       }
  62.  
  63.    }
  64. }
  65.